package com.huatai.bpmn.mapper;

import cn.hutool.json.JSONObject;
import com.huatai.bpmn.entity.InvestCapitalEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huatai.bpmn.entity.dto.CandidateTaskDto;
import com.huatai.bpmn.entity.vo.HistoryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 实施详情表格
 *
 * @author yxy
 * @email yuanxy999@126.com
 * @date 2024-07-19 10:41:47
 */
@Mapper
public interface InvestCapitalMapper extends BaseMapper<InvestCapitalEntity> {

	@Select("select distinct user_id,user_name from tb_invest_capital where flow_id=#{flowId}")
	List<JSONObject> getUserIdByFlowId(String flowId);

	@Select("select * from tb_invest_capital where user_id=#{userid} and flow_id=#{flowId}")
	List<InvestCapitalEntity> getListByUserIdAndFlowId(String userid, String flowId);

	@Select("SELECT  " +
		"h.PROC_INST_ID_ as processInstanceId,h.EXECUTION_ID_, " +
		"h.TASK_ID_ as taskId, " +
		"h.ACT_NAME_ as activityName,h.ACT_TYPE_ as actType, " +
		"h.ASSIGNEE_, " +
		"h.START_TIME_ as startTime,h.END_TIME_ as endTime, " +
		"b.deploy_id as deployId, " +
		"t.FORM_KEY_ as nodeForm, " +
		"c.`status`,c.approval_proposal " +
		"FROM act_hi_actinst h " +
		"LEFT JOIN act_hi_taskinst t " +
		"ON h.TASK_ID_ = t.ID_ " +
		"LEFT JOIN tb_complete_task_status c " +
		"ON h.TASK_ID_=c.task_id " +
		"LEFT JOIN tb_business b " +
		"ON h.PROC_INST_ID_=b.procinst_id " +
		"WHERE h.PROC_INST_ID_='${processId}' " +
		"ORDER BY h.START_TIME_ ASC")
	List<HistoryVO> taskHistoryInfo(String processId);

}
